package com.sg.fileService.util;


import org.apache.commons.lang3.StringUtils;

import com.sg.fileService.config.Property;

import it.sauronsoftware.jave.AudioAttributes;
import it.sauronsoftware.jave.EncoderException;
import it.sauronsoftware.jave.EncodingAttributes;
import it.sauronsoftware.jave.InputFormatException;
import it.sauronsoftware.jave.VideoSize;

/**
 * 音视频转换-音频文件转MP3
 * @author xzk
 * @version 1.0
 * @date 20180224
 *
 */
public class MP3AVEncoder extends AbsAVEncoder{
	
	public MP3AVEncoder() {
		//Property.AUDIO_FORMAT_TYPE为MP3的时候使用mp3的转码方式
		super("mp3",Property.AUDIO_FORMAT_TYPE);
	}
	
	/**
	 * 音频转换参数设置
	 * @param videoSize
	 * @throws IllegalArgumentException
	 * @throws InputFormatException
	 * @throws EncoderException
	 */
	@Override
	public EncodingAttributes initEncodeAttr(VideoSize videoSize){
			
	        //设置音频参数
	        AudioAttributes audio = new AudioAttributes();
	        //--acodec
	        audio.setCodec("libmp3lame");
	        
	        
	        //设置转换器参数
	        EncodingAttributes attrs = new EncodingAttributes();
	        attrs.setFormat(null);//-f
	        attrs.setAudioAttributes(audio);
	        
	        return attrs;
	}
	
}
